home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / Xpm1.tcl.z / Xpm1.tcl
Encoding:
Text File  |  1999-01-26  |  3.2 KB  |  105 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of XPM images in the menu.
  10. #
  11.  
  12. proc RunSample {w} {
  13.  
  14.     set hard_disk_pixmap {/* XPM */
  15.     static char * drivea_xpm[] = {
  16.         /* width height ncolors chars_per_pixel */
  17.         "32 32 5 1",
  18.         /* colors */
  19.         "     s None    c None",
  20.         ".    c #000000000000",
  21.         "X    c white",
  22.         "o    c #c000c000c000",
  23.         "O    c #800080008000",
  24.         /* pixels */
  25.         "                                ",
  26.         "                                ",
  27.         "                                ",
  28.         "                                ",
  29.         "                                ",
  30.         "                                ",
  31.         "                                ",
  32.         "                                ",
  33.         "                                ",
  34.         "   ..........................   ",
  35.         "   .XXXXXXXXXXXXXXXXXXXXXXXo.   ",
  36.         "   .XooooooooooooooooooooooO.   ",
  37.         "   .Xooooooooooooooooo..oooO.   ",
  38.         "   .Xooooooooooooooooo..oooO.   ",
  39.         "   .XooooooooooooooooooooooO.   ",
  40.         "   .Xoooooooo.......oooooooO.   ",
  41.         "   .Xoo...................oO.   ",
  42.         "   .Xoooooooo.......oooooooO.   ",
  43.         "   .XooooooooooooooooooooooO.   ",
  44.         "   .XooooooooooooooooooooooO.   ",
  45.         "   .XooooooooooooooooooooooO.   ",
  46.         "   .XooooooooooooooooooooooO.   ",
  47.         "   .oOOOOOOOOOOOOOOOOOOOOOOO.   ",
  48.         "   ..........................   ",
  49.         "                                ",
  50.         "                                ",
  51.         "                                ",
  52.         "                                ",
  53.         "                                ",
  54.         "                                ",
  55.         "                                ",
  56.         "                                "};
  57.     }
  58.     # We create the frame and the ScrolledText widget
  59.     # at the top of the dialog box
  60.     #
  61.     frame $w.top -relief raised -bd 1
  62.  
  63.     set m [frame $w.top.menu -relief raised -bd 2]
  64.     set mb [menubutton $m.mb -text Options -menu $m.mb.m]
  65.     set menu [menu $mb.m]
  66.  
  67.     pack $m -side top -fill x
  68.     pack $mb -side left -fill y
  69.  
  70.     # Put the label there
  71.     #
  72.     set lab [label $w.top.label -text "Go to the \"Options\" menu" -anchor c]
  73.     pack $lab -padx 40 -pady 40 -fill both -expand yes
  74.  
  75.     set image [image create pixmap -data $hard_disk_pixmap]
  76.     $menu add command -image  $image \
  77.     -command "$lab config -image $image"
  78.  
  79.     # Use a ButtonBox to hold the buttons.
  80.     #
  81.     tixButtonBox $w.box -orientation horizontal
  82.     $w.box add ok     -text Ok     -underline 0 -command "destroy $w" \
  83.     -width 6
  84.     $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  85.     -width 6
  86.  
  87.     pack $w.box -side bottom -fill x
  88.     pack $w.top -side top -fill both -expand yes
  89.  
  90.     wm geometry $w 300x300
  91. }
  92.  
  93.  
  94. # This "if" statement makes it possible to run this script file inside or
  95. # outside of the main demo program "widget".
  96. #
  97. if {![info exists tix_demo_running]} {
  98.     wm withdraw .
  99.     set w .demo
  100.     toplevel $w
  101.     RunSample $w
  102.     bind .demo <Destroy> exit
  103. }
  104.  
  105.